home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
WEBSITES
/
MARKWART
/
BIOMORPH.ZIP
/
!BioMorph
/
WWv2Data
< prev
Wrap
Text File
|
1999-01-10
|
7KB
|
345 lines
# WimpWorks Information File
# WimpWorks © Jaffa Software 1997. All rights reserved.
DEF TASKdetails
Name BioMorph
Purpose Bug Breeding
Author © Victor Markwart
Licence FreeWare
Version 0.01
Compress True
Memory 0K
IconbarSide Right
IconbarPriority &00000000
IconbarSprite !biomorph
IconbarText
ENDTASK
DEF WEMinclude
Starter Pack
ENDWEM
DEF MENUiconMenu%
BioMorph
Info
S(infoWindow%)
Start
PROCreinit
Quit
CLOSEDOWN
ENDMENU
DEF SUBR_PROCmenu_klik
Event 3
Every -1
DEF PROCmenu_klik(button%)
IF button%<>2 THEN
IF gen=0 THEN
OPENWINDOW(Start)
ELSE
OPENWINDOW(Biomorph)
ENDIF
ENDIF
ENDPROC
ENDSUBR
DEF SUBR_PROCinit
Event 0
Every -1
DEF PROCinit
DIM morph(6,12)
DIM gi(5,2), px(12), py(12)
REM Read in increments and limits (min & max) of each gene
RESTORE +1
FOR A%=0 TO 2
FOR B%=0 TO 5
READ gi(B%, A%)
NEXT
NEXT
R=RND(TIME)
DATA 1,4,0.16, 0.2, 0.16, 2: REM Gene increment value
DATA 1,-36, -3.14, 0.1, -3.14, -18: REM Gene minimum value
DATA 9, 36, 3.14, 10, 3.14, 18 : REM Gene maximum value
PROC_INTPOS: REM Initialise display position
PROC_INTP : REM Initialise gene value
gen=0
col%=&00FF0000
bug_col%=&0000FF00
SETSTATE(Biomorph, 4, TRUE)
SETSTATE(Start, 5, TRUE)
SETICON(Biomorph, 17, "Generation 0")
HIDEICON(Biomorph, 4, TRUE) : REM Parent selection - superfluous
HIDEICON(Biomorph, 1, TRUE) : REM Save - not implemented yet
PROC_LINES
ENDPROC
ENDSUBR
DEF SUBR_PROC_MUTATE
Event -1
Every -1
DEF PROC_MUTATE
a%=-1
FOR b%=1 TO 12
FOR c%=0 TO 5
morph(c%,b%)=morph(c%,0)
NEXT
c%=b% MOD 2
a%=a%+c%
IF c%=1 THEN d%=-1 ELSE d%=1
morph(a%,b%)+=d%*gi(a%,0)
IF (morph(a%, b%) < gi(a%,1)) THEN morph(a%,b%)=gi(a%,1)
IF (morph(a%, b%) > gi(a%,2)) THEN morph(a%,b%)=gi(a%,2)
NEXT
ENDPROC
ENDSUBR
DEF SUBR_PROC_INTP
Event -1
Every -1
DEF PROC_INTP
morph(0,0)=3
morph(1,0)=20
morph(2,0)=.96
morph(3,0)=1
morph(4,0)=0.48
morph(5,0)=0
FOR i=1 TO 12
FOR j=0 TO 5
morph(j,i)=0
NEXT
NEXT
ENDPROC
ENDSUBR
DEF SUBR_PROC_DISPLAY
Event -1
Every -1
DEF PROC_DISPLAY
HOURPERCENT(0,12)
CLWIN(Biomorph)
percent=100/12
PROC_LINES
FOR A%=0 TO 12
PROC_TREE(morph(0, A%), morph(1, A%), morph(2, A%), morph(3, A%), morph(4, A%), morph(5, A%), px(A%), py(A%))
HOURPERCENT(A%,12)
NEXT
REDRAW(Biomorph)
ENDPROC
ENDSUBR
DEF SUBR_PROC_INTPOS
Event -1
Every -1
DEF PROC_INTPOS
RESTORE +1
FOR A= 0 TO 12
READ px(A), py(A)
NEXT
DATA 800, 348
DATA 160, 92, 480, 92, 800, 92, 1120, 92
DATA 160, 348, 1120, 348
DATA 160, 604, 1120, 604
DATA 160, 860, 480, 860, 800, 860, 1120, 860
flag%=FALSE
ENDPROC
ENDSUBR
DEF SUBR_PROC_LINES
Event -1
Every -1
DEF PROC_LINES
FOR x%=320 TO 960 STEP 320
FOR y%=256 TO 768 STEP 256
LINE(Biomorph, x%, 0, x%,-1023, col%)
LINE(Biomorph, 0, -y%, 1259, -y%, col%)
NEXT
NEXT
LINE(Biomorph, 640, -260, 640, -764, col%)
LINE(Biomorph, 324, -512, 958, -512, col%)
SETICON(Biomorph, 18, "Parent Biomorph")
REDRAW(Biomorph)
ENDPROC
ENDSUBR
DEF SUBR_PROC_CHOSE
Event -1
Every -1
DEF PROC_CHOSE
VDU5:MOVE 360,290
PRINT "? or Breed from CHILD (A-L)?";:*FX15
A$=GET$
A=ASC(A$)
A=A EOR 32
A$=CHR$(A)
PRINT A$;:C%=ASC(A$)-&40
IF C%<0 OR C%>12 PROC_REVIEW: ENDPROC
FOR A%=0 TO 5
morph(A%,0)=morph(A%,C%)
NEXT
ENDPROC
ENDSUBR
DEF SUBR_PROC_TREE
Event -1
Every -1
DEF PROC_TREE(D,L,dA,AR,DT,DS,X,Y)
LINE(Biomorph, X, -Y, X,-(Y-L), bug_col%)
PROC_GROW(PI/2, L, X, Y, D)
ENDPROC
ENDSUBR
DEF SUBR_PROC_GROW
Event -1
Every -1
DEF PROC_GROW(TH,L,X,Y,D)
IF D<0 ENDPROC
IF AR=0 THEN AR=.1
dX=L*COS(TH+dA)*(1/AR)
dY=L*SIN(TH+dA)*AR
LINE(Biomorph, X, -Y,X+dX,-Y-dY, bug_col%)
PROC_GROW(TH+dA+DT, L-DS,X+dX,Y+dY,D-1)
dX=L*COS(TH-dA)*(1/AR)
dY=L*SIN(TH-dA)*AR
LINE(Biomorph, X, -Y,X+dX,-Y-dY, bug_col%)
PROC_GROW(TH-dA-DT, L-DS, X+dX, Y+dY, D-1)
ENDPROC
ENDSUBR
DEF SUBR_PROCwindow_klik
Event 12
Every -1
DEF PROCwindow_klik(window%, icon%, button%)
CASE window% OF
WHEN Biomorph:
CASE icon% OF
WHEN 0: REM Breed
gen=gen + 1
SETICON(Biomorph, 17, "Generation "+STR$(gen))
par%=GROUPSTATE(Biomorph, 1)-4
IF par%<0 THEN
WARNING("Please choose a parent", "Biomorph")
ELSE
FOR i=0 TO 5
morph(i,0)= morph(i,par%)
NEXT
HOURON
PROC_MUTATE
PROC_DISPLAY
HOUROFF
ENDIF
WHEN 1:
WHEN 2: REM Close
CLOSEWINDOW(window%)
WHEN 3: REM Current values
par%=GROUPSTATE(Biomorph, 1)-4
IF par%<0 THEN
WARNING("Please choose a parent", "Biomorph")
ELSE
FOR i=0 TO 5
SETICON(Gene, 2+i, STR$(morph(i,par%)))
NEXT
ENDIF
OPENWINDOW(Gene)
ENDCASE
WHEN Gene:
CASE icon% OF
WHEN 0:
FOR i=0 TO 5
a$=READICON(window%, i+2)
IF a$="" THEN a$="1"
morph(i,0)=EVAL(a$)
NEXT
REM Check values
PROCcheck
IF button%=4 THEN CLOSEWINDOW(window%)
OPENWINDOW(Biomorph)
PROC_DISPLAY
WHEN 1:
CLOSEWINDOW(window%)
ENDCASE
WHEN Start:
CASE icon% OF
WHEN 0:
option%=GROUPSTATE(window%, 1) - 4
a$=STR$(option%)
CASE option% OF
WHEN 1:
PROC_INTP
CLOSEWINDOW(Start)
OPENWINDOW(Biomorph)
PROC_TREE(morph(0,0), morph(1,0), morph(2,0), morph(3,0), morph(4,0), morph(5,0), px(0), py(0))
REDRAW(Biomorph)
WHEN 2:
FOR A%=0 TO 5
inc=(gi(A%,2)-gi(A%,1))/100
morph(A%,0)=RND(100) *inc + gi(A%,0)
NEXT
morph(0,0)=INT(morph(0,0))
CLOSEWINDOW(Start)
OPENWINDOW(Biomorph)
PROC_TREE(morph(0,0), morph(1,0), morph(2,0), morph(3,0), morph(4,0), morph(5,0), px(0), py(0))
REDRAW(Biomorph)
WHEN 3:
CLOSEWINDOW(Start)
OPENWINDOW(Gene)
OTHERWISE:
WARNING("You must select an option!", "Biomorph")
ENDCASE
WHEN 1:
CLOSEWINDOW(window%)
ENDCASE
ENDCASE
ENDPROC
ENDSUBR
DEF SUBR_PROCcheck
Event -1
Every -1
DEF PROCcheck
flag%=FALSE
FOR A%=0 TO 5
msg$="Gene values should be between: "+CHR$(10)
IF morph(A%,0)<gi(A%,1) THEN
flag%=TRUE
msg$=msg$ + "Gene " + STR$(A%) + "should be > " + STR$(gi(A%,1))
morph(A%,0)=gi(A%,1)
ENDIF
IF morph(A%,0)>gi(A%,2) OR morph(A%,0)<gi(A%,1) THEN
flag%=TRUE
msg$=msg$ + "Gene " + STR$(A%) + " should be < "+STR$(gi(A%,1))
morph(A%,0)=gi(A%,2)
ENDIF
NEXT
IF flag%=TRUE THEN WARNING(msg$, "Biomorph")
ENDPROC
ENDSUBR
DEF SUBR_PROCreinit
Event -1
Every -1
DEF PROCreinit
PROC_INTP : REM Initialise gene value
FOR i=5 TO 16
SETSTATE(Biomorph, i, FALSE)
NEXT
SETSTATE(Biomorph, 4, TRUE)
CLWIN(Biomorph)
PROC_LINES
CLOSEWINDOW(Biomorph)
OPENWINDOW(Start)
gen=0
SETICON(Biomorph, 17, "Generation "+STR$(gen))
ENDPROC
ENDSUBR